package com.bridgeintelligent.tag.constants;

import com.wayneleo.quickstart.framework.BaseException;
import lombok.Getter;

@Getter
public enum Permissions {

    WORKFLOW_DEFINITION_10001("审批创建自定义标签", "10001", ""),
    WORKFLOW_DEFINITION_10002("审批修改自定义标签", "10002", ""),
    WORKFLOW_DEFINITION_10003("审批删除自定义标签", "10003", ""),
    WORKFLOW_DEFINITION_10004("审批清理自定义标签", "10004", ""),
    WORKFLOW_DEFINITION_10005("审批上传文件新增自定义标签数据", "10005", ""),
    WORKFLOW_DEFINITION_10006("审批上传文件删除自定义标签数据", "10006", ""),
    WORKFLOW_DEFINITION_10007("新建", "10007", ""),//审批创建组合标签数据
    WORKFLOW_DEFINITION_10008("导出下载", "10008", ""),//审批导出客群
    WORKFLOW_DEFINITION_10009("新建", "10009", ""),//审批发布客群
    WORKFLOW_DEFINITION_10010("删除", "10010", ""),//审批删除客群
    WORKFLOW_DEFINITION_10016("导出下发", "10016", ""),//审批删除客群
    /* 自动审核 系列 */
    WORKFLOW_DEFINITION_10011("定制标签新建自动审核通过", "10011", "/data/audit/auto/free/add"),
    WORKFLOW_DEFINITION_10012("组合标签发布自动审核通过", "10012", "/data/audit/auto/combination/add"),
    WORKFLOW_DEFINITION_10013("客群导出申请自动审核通过", "10013", "/data/audit/auto/customers/export"),
    WORKFLOW_DEFINITION_10014("客群发布申请自动审核通过", "10014", "/data/audit/auto/customers/add"),
    WORKFLOW_DEFINITION_10015("客群删除申请自动审核通过", "10015", "/data/audit/auto/customers/delete"),

    /* 标签管理-基础标签 */
    WORKFLOW_DEFINITION_21001("查看", "21001", "/api/dimMgmt/list"),
    WORKFLOW_DEFINITION_21002_1("收藏/取消收藏", "21002", "/api/dimMine/add"),
    WORKFLOW_DEFINITION_21002_2("收藏/取消收藏", "21002", "/api/dimMine/del"),

    /* 标签管理-自定义标签 */
    WORKFLOW_DEFINITION_22001("查看", "22001", "/api/dimFree/list"),
    WORKFLOW_DEFINITION_22002("新建", "22002", "/api/dimFree/add"),
    WORKFLOW_DEFINITION_22003("编辑", "22003", "/api/dimFree/updateBaseInfo"),
    WORKFLOW_DEFINITION_22004("删除", "22004", "/api/dimFree/del"),
    WORKFLOW_DEFINITION_22005("清理", "22005", "/api/dimFree/clear"),
    WORKFLOW_DEFINITION_22006("授权", "22006", ""),

    /* 标签管理-我的标签 */
    WORKFLOW_DEFINITION_23001("收藏标签列表", "23001", "/api/dimMine/list"),
    WORKFLOW_DEFINITION_23002("审核标签列表", "23002", "/api/dimFreeApproval/findList"),

    /* 系统管理-用户管理 */
    WORKFLOW_DEFINITION_31001("查看", "31001", "/api/user/list"),
    WORKFLOW_DEFINITION_31002("新建", "31002", "/api/user/add"),
    WORKFLOW_DEFINITION_31003("编辑", "31003", "/api/user/update"),
    WORKFLOW_DEFINITION_31004("删除", "31004", "/api/user/delete/*"),
    WORKFLOW_DEFINITION_31005("批量导入", "31005", "/api/user/upload"),
    WORKFLOW_DEFINITION_31006("分配角色", "31006", "/api/user/update"),
    WORKFLOW_DEFINITION_31007("启用/关闭", "31007", "/api/user/update"),

    /* 系统管理-角色管理 */
    WORKFLOW_DEFINITION_32001("查看", "32001", "/api/role/list"),
    WORKFLOW_DEFINITION_32002("新建", "32002", "/api/role/add"),
    WORKFLOW_DEFINITION_32003("编辑", "32003", "/api/role/update"),
    WORKFLOW_DEFINITION_32004("删除", "32004", "/api/role/delete/*"),

    /* 系统管理-标签目录管理 */
    WORKFLOW_DEFINITION_33001("查看", "33001", "/api/dimCatalog/list"),
    WORKFLOW_DEFINITION_33002("新增目录", "33002", "/api/dimCatalog/add"),
    WORKFLOW_DEFINITION_33003("修改目录", "33003", "/api/dimCatalog/update"),
    WORKFLOW_DEFINITION_33004("删除目录", "33004", "/api/dimCatalog/del"),
    WORKFLOW_DEFINITION_33005("移动目录", "33005", "/api/dimCatalog/update"),
    WORKFLOW_DEFINITION_33006("移动标签", "33006", "/api/dimMgmt/update"),

    /* 系统管理-基础标签管理 */
    WORKFLOW_DEFINITION_34001("新建 ", "34001", "/api/dimMgmt/add"),
    WORKFLOW_DEFINITION_34002("批量导入", "34002", "/api/dimExport/doExport"),
    WORKFLOW_DEFINITION_34003("查看", "34003", "/api/dimMgmt/list"),
    WORKFLOW_DEFINITION_34004("编辑", "34004", "/api/dimMgmt/update"),
    WORKFLOW_DEFINITION_34005("删除", "34005", "/api/dimMgmt/del"),
    WORKFLOW_DEFINITION_34006("启用/停用", "34006", "/api/dimMgmt/changeState"),

    /* 客群管理-客群列表 */
    WORKFLOW_DEFINITION_41001("查看客群详情 ", "41001", "/api/customers/findOneById"),
    WORKFLOW_DEFINITION_41002("查看客群数量 ", "41002", "/api/query/customerGroup"),
    WORKFLOW_DEFINITION_41003("选择渠道 ", "41003", ""),
    WORKFLOW_DEFINITION_41004("客群画像 ", "41004", ""),

    /* 客群管理-客群筛选 */
    WORKFLOW_DEFINITION_42001("新建客群 ", "42001", "/api/customers/add"),
    WORKFLOW_DEFINITION_42002("筛选客群 ", "42002", "/api/query/customerGroup"),
    WORKFLOW_DEFINITION_42003("查看符合条件的客群列表 ", "42003", "/api/query/dataSet");

    /* 客群管理-客群筛选 */
    //WORKFLOW_DEFINITION_43001("查看详情", "43001", "/api/customers/findOneById"),
    //WORKFLOW_DEFINITION_43002("编辑", "43002", "/api/customers/update"),
    //WORKFLOW_DEFINITION_43003("授权", "43003", ""),
    //WORKFLOW_DEFINITION_43004("删除", "43004", "/api/customers/delCustomers"),
    //WORKFLOW_DEFINITION_43005("选择渠道", "43005", "");


    /**
     * **************************************** 分割线 ******************************************
     */

    String name;
    String code; // ID
    String url;

    Permissions(String name, String code, String url) {
        this.name = name;
        this.code = code;
        this.url = url;
    }

    public static Permissions of(String code) {
        for (Permissions permission : values()) {
            if (permission.code.equals(code)) {
                return permission;
            }
        }
        throw new BaseException(ExceptionCodes.SECURITY_50002);
    }
}
